package cn.edu.hizee.gps.dao;

import cn.edu.hizee.gps.model.User;
import cn.edu.hizee.gps.model.UserContact;
import org.apache.ibatis.annotations.Param;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;

import java.util.List;


/**
 * @author ZX
 */
public interface UserContactRepository extends JpaRepository<UserContact,Integer>, CrudRepository<UserContact,Integer> {


    @Query(nativeQuery = true, value = "UPDATE t_contact AS c  " +
            "SET c.is_disable = :isDisable  " +
            "WHERE " +
            "EXISTS ( SELECT 1 FROM t_user_contact as uc WHERE c.id = :contactId AND uc.user_id = :userId)")
    Integer deleteContact(@Param("isDisable") Integer isDisable,@Param("userId") Integer userId, @Param("contactId") Integer contactId);

}
